Subject: Re: Look at this 24 lines of code
From: Richard Barry Ling <[email-masked]>
To: [email-masked] (AMOS User group)
Date: Sat, 4 Sep 1993 10:51:50 +1000 (EST)

> HI everyone!!!
> I recently posted some help on a flickering bob routine
> and got about 5 different answers, three of them worked,
> but two of them were FAST, and so I decided to use the
> shortest one of the two.
> 
> Now my problem is, when I tried the piece of code
> in a small individual program, everything worked fine,
> BUT when I tried it in my real-life 24k program, for
> some reason I get NOTHING on the screen!!!
> 
> So here's the 24k code reduced to about 24 lines,
> I'll just show you the commands that have anything
> to do whith handling graphics, ok? here it is:
> 
> 
> screen open 1,352,240,32,lowres
> load iff "infest:gameboard",1
> screen display 1,,20,,
> screen to front 1
> load iff "infest:players",2
> screen to back 2
> change mouse 2
> double buffer
> autoback 0
> update off
> 	.
> 	.
> 	.
> load "infest:infestbobs.abk",1
> screen 1
> load "infest:samples.abk",1
> sam bank 1
> 	.
> 	.
> 	.
> Piece-Anim : rem calls the procedure you guys helped me with
> 	.
> 	.
> 	.
> procedure Piece-Anim
> for range=rangeL to rangeR
>    bob clear
>    bob 1,xblit,yblit,range
>    bob draw
>    screen swap
>    wait 2
> next range
> end proc
> 
> rem this is it!, so what am I doing wrong here?????????????

Well, as Andy pointed out, you can't load two data files into bank 1, since
the previous bank gets forgotten.

The other thing is that you're opening screen 2, which selects screen 2 as
the current screen; then you call double buffer, which double buffers screen
2 (always double buffers the current screen!) and then you're selecting
screen 1 again and doing the animation, and screen 1 isn't double buffered!
So even if you could display the animation, it would still flicker.

For the above program, I suggest calling Double Buffer right after opening
the screen 1.

A couple of other pointers:

 * opening a screen brings it to the front, so no need for
   screen to front 1.  It also "selects" that screen.

 * using Load Iff with a screen number automagically opens a screen
   appropriate for the picture, closing any screen with the same screen
   number.  which means that your example opens screen 1, then, when you
   call Load Iff, closes it and opens it again.

 * Are you still using screen 0 (the default screen)?  Otherwise it stays
   open, wasting memory.  Substitute screens 0 and 1 for 1 and 2 and you'll
   save quite a bit of chip RAM.

I'd use this:

load iff "infest:players",0		replace default screen with
					your "players" picture

load iff "infest:gameboard",1		this puts screen 1 in front
screen display 1,,20,,
double buffer				double buffer screen 1
autoback 0
update off
change mouse 2

then go on with your animation etc. using screen 1..

> p.s.: Are there any books that actually EXPLAIN what each
>       command REALLY does and how it AFFECTS other commads
>       later on in your code???

This is something that annoyed me a bit about AMOS at first, too.  There are
so many commands which affect each other, but no real indication of how they
interact.  I just used trial and error.... lots of trial, and lots of errors!

> sincerely,
> 	[email-masked]
> 
> p.s.: THANKS in advance everyone!!!
> 

Hey, no problem!! :-)

RL.

This has been a dinosaur-free announcement.

==========================  Generating: .signature
   Richard Ling             - colour analysis... complete
 [email-masked]     - clipping... complete
==========================  - rendering... 37.6%